﻿using MVCDemo.Models;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace MVCDemo.Controllers
{
    public class DepartmentController : Controller
    {
        public ActionResult Index()
        {
            EmployeeContext employeeContext = new EmployeeContext();
            List<Department> departments=employeeContext.Departments.ToList();

            return View(departments);
        }

        [HttpGet]
        public ActionResult RadioButtonList()
        {
            Company company = new Company();
            return View(company);
        }

        [HttpPost]
        public string RadioButtonList(Company company)
        {
            if(string.IsNullOrEmpty(company.SelectedDepartment))
            {
                return "You did not selected any department";
            }
            else
            {
                return "You selected department with Id : " + company.SelectedDepartment;
            }
        }
    }
}
